package io.gitee.hechenl.fastiotreport.controller.converter;

import io.gitee.hechenl.fastiotreport.domain.dto.ImportPointDTO;
import io.gitee.hechenl.fastiotreport.domain.vo.PointListVO;
import io.gitee.hechenl.fastiotreport.domain.model.ConfigPoint;
import org.springframework.util.CollectionUtils;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public class ConfigPointConverter {

    public static List<ConfigPoint> toInsertModelList(List<ImportPointDTO> items) {
        if (CollectionUtils.isEmpty(items)) {
            return Collections.emptyList();
        }
        return items.stream().map(v -> {
            ConfigPoint configPoint = new ConfigPoint();
            configPoint.setPointId(v.getPointId());
            configPoint.setPointName(v.getPointName());
            return configPoint;
        }).collect(Collectors.toList());
    }

    public static List<PointListVO> toVOList(List<ConfigPoint> list) {
        if (CollectionUtils.isEmpty(list)) {
            return Collections.emptyList();
        }
        return list.stream().map(v -> {
            PointListVO VO = new PointListVO();
            VO.setPointId(v.getPointId());
            VO.setPointName(v.getPointName());
            return VO;
        }).collect(Collectors.toList());
    }
}
